package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum AnnouncementStatus {
    UNPUBLISHED(0, "未发布"),
    PUBLISHED(1, "已发布");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static AnnouncementStatus formValue(Object o) {
        if (o != null) {
            AnnouncementStatus[] announcementStatuses = values();
            for (AnnouncementStatus announcementStatus : announcementStatuses) {
                if (announcementStatus.getValue().equals(o)) {
                    return announcementStatus;
                }
            }
        }
        return null;
    }

    public static AnnouncementStatus formLabel(Object o) {
        if (o != null) {
            AnnouncementStatus[] announcementStatuses = values();
            for (AnnouncementStatus announcementStatus : announcementStatuses) {
                if (announcementStatus.getLabel().equals(o)) {
                    return announcementStatus;
                }
            }
        }
        return null;
    }

}
